<?php
/**
 * CompleXml Framework
 *
 * @category   CompleXml
 * @package    CompleXml_Request
 * @copyright  Copyright (c) 2008 Andrey Kucherenko
 * @license    New BSD License
 * @version    $Id: Request.php 8 2008-11-13 14:50:42Z kucherenko.andrey $
 */

require_once 'CompleXml/Dataset/Abstract.php';
class CompleXml_Dataset_Request extends CompleXml_Dataset_Abstract
{
    const REQUEST = 0;
    const POST = 1;
    const GET = 2;
    const URI = 3;
    public $Post;
    public $Get;
    public $Uri;
    public function __construct ($source_type = CompleXml_Dataset_Request::REQUEST)
    {
        switch ($source_type) {
            case self::REQUEST:
                $source = $_REQUEST;
                $this->Post = new self(self::POST);
                $this->Get = new self(self::GET);
                $this->Uri = new self(self::URI);
                break;
            case self::POST:
                $source = $_POST;
                break;
            case self::GET:
                $source = $_GET;
                break;
            case self::URI:
                $source = self::__clear_array(explode('/', getenv('REQUEST_URI')));
                break;
        }
        parent::__construct($source);
    }
    private static function __clear_array ($array)
    {
        $result = array(
            
        );
        for ($i = 0; $i < count($array); $i ++) {
            if (! (trim($array[ $i ]) == "")) {
                $result[] = $array[ $i ];
            }
        }
        return $result;
    }
}
